import http from '@/http';
import type {Follow, ResponseData} from '@/types/interface';

const followApi = {
    // 关注用户
    followUser: (followedUserId: number): Promise<ResponseData<boolean>> => {
        return http.post('/follow/add', { followedUserId });
    },

    // 取消关注
    cancelFollow: (followedUserId: number): Promise<ResponseData<boolean>> => {
        return http.post('/follow/cancel', { followedUserId });
    },

    // 获取关注列表
    getFollowList: (userId: number, page: number, size: number): Promise<ResponseData<{
        list: Follow[];
        total: number;
    }>> => {
        return http.get(`/follow/list?userId=${userId}&page=${page}&size=${size}`);
    },

    // 获取粉丝列表
    getFansList: (userId: number, page: number, size: number): Promise<ResponseData<{
        list: Follow[];
        total: number;
    }>> => {
        return http.get(`/follow/fans?userId=${userId}&page=${page}&size=${size}`);
    },

    // 检查是否已关注
    checkFollow: (followedUserId: number): Promise<ResponseData<{ isFollow: boolean }>> => {
        return http.get(`/follow/check?followedUserId=${followedUserId}`);
    }
};

export default followApi;